package com.changli04._set.exer1;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class hashSetTest {
    public static void main(String[] args) {
        List list = new ArrayList();
        for (int i = 0; i < 10; i++) {
            int random = (int) (Math.random() * 10);
            list.add(random);

        }
        System.out.println(list);
        List list1 = duplicateList(list);
        System.out.println(list1);
    }


    public static List duplicateList (List list){
        HashSet set = new HashSet();
        List newList = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            set.add(list.get(i));

        }
        newList.addAll(set);

        return newList;
    }
}
